package com.walsai.pcsys.core.model;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;


@Embeddable
public class SolutionPK implements Serializable {
	private static final long serialVersionUID = 74646383L;

	private Problem problem; // required
	private User user;

	@ManyToOne
	public Problem getProblem() {
		return problem;
	}

	@ManyToOne
	public User getUser() {
		return user;
	}

	public void setProblem(Problem problem) {
		this.problem = problem;
	}

	public void setUser(User user) {
		this.user = user;
	}

	@Override
	public boolean equals(Object o) {
		boolean result = false;
		if (o != null && getClass() == o.getClass()) {
			final SolutionPK p = (SolutionPK) o;
			if (this.problem.equals(p.problem) && this.user.equals(p.user)) {
				result = true;
			}
		}
		return result;
	}

	@Override
	public int hashCode() {
		return this.problem.hashCode() + this.user.hashCode();
	}
}
